﻿using UnityEngine;

namespace Gp.Scripts.Character {
    public class FovPlane {
        private Vector3 normal;
        private float coefficientD;
        public Vector3 Normal => normal;
        public FovPlane(Vector3 a, Vector3 b, Vector3 c) {
            Vector3 ab = b - a;
            Vector3 ac = c - a;
            normal = Vector3.Cross(ab, ac).normalized;
            coefficientD = -normal.x * a.x - normal.y * a.y - normal.z * a.z;
        }
        public bool OnNormalSide(Vector3 point) {
            return normal.x * point.x + normal.y * point.y + normal.z * point.z + coefficientD > 0.0f;
        }
    }
}